package cn.hrlly.tao2shou.presenter;

import cn.hrlly.tao2shou.biz.ClassifyCommoditiesBiz;
import cn.hrlly.tao2shou.biz.ClassifyCommoditiesBizImpl;
import cn.hrlly.tao2shou.domain.CommodityList;
import cn.hrlly.tao2shou.listener.OnClassifyCommoditiesListener;
import cn.hrlly.tao2shou.view.view_interface.ClassifyCommoditiesView;

/**
 * User: gengliang
 * Date: 2016-01-29
 * Time: 19:53
 */

public class ClassifyCommoditiesPresenterImpl implements ClassifyCommoditiesPresenter,OnClassifyCommoditiesListener {

    private ClassifyCommoditiesBiz classifyCommoditiesBiz;
    private ClassifyCommoditiesView classifyCommoditiesView;

    public ClassifyCommoditiesPresenterImpl(ClassifyCommoditiesView classifyCommoditiesView){
        this.classifyCommoditiesBiz=new ClassifyCommoditiesBizImpl(this);
        this.classifyCommoditiesView=classifyCommoditiesView;
    }

    @Override
    public void showClassifyCommodities() {
        CommodityList commodityList=new CommodityList();
        commodityList.setClassification(classifyCommoditiesView.getClassification());
        commodityList.setPage(classifyCommoditiesView.getPage());
        commodityList.setPageCount(classifyCommoditiesView.getPageCount());
        commodityList.setSortAccording(classifyCommoditiesView.getSortAccording());
        commodityList.setLongitude(classifyCommoditiesView.getLongitude());
        commodityList.setLantitude(classifyCommoditiesView.getLantitude());
        classifyCommoditiesBiz.showClassifyCommodities(commodityList);
    }

    @Override
    public void showClassifyCommoditiesSucc(CommodityList commodityList) {
        classifyCommoditiesView.showListView(commodityList);
    }

    @Override
    public void showClassifyCommoditiesFail(String errorMessage) {
        classifyCommoditiesView.showMessage(errorMessage);
    }

    @Override
    public void showClassifyCommoditiesFail(int errorMessage) {
        classifyCommoditiesView.showMessage(errorMessage);
    }
}
